<!DOCTYPE html>
<html lang="en">
<head>
	<title>登录</title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<meta name="description" content="">
	<meta name="author" content="banyehcan">
	<!-- Bootstrap core CSS -->
	<link rel="stylesheet" href="${request.contextPath }/css/bootstrap/css/bootstrap.min.css" rel="stylesheet">
	<!-- Endless -->
	<link href="${request.contextPath }/css/bootstrap/css/endless.min.css" rel="stylesheet">
	<!-- Font Awesome -->
	<link href="${request.contextPath }/css/bootstrap/css/font-awesome.min.css" rel="stylesheet">
	<link rel="stylesheet" href="${request.contextPath }/css/alertify/alertify.core.css">
	<link rel="stylesheet" href="${request.contextPath }/css/alertify/alertify.bootstrap.css">
	
	
	<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
	<script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
	<script src="${request.contextPath }/css/bootstrap/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="${request.contextPath }/js/parsley.min.js"></script>
	<script type="text/javascript" src="${request.contextPath }/js/alertify/alertify.min.js"></script>
	
  </head>

  <body>
	<div class="login-wrapper">
		<div class="text-center">
			<h2 class="fadeInUp animation-delay8" style="font-weight:bold">
				<span class="text-success">车次</span> <span style="color:#ccc; text-shadow:0 1px #fff">管理</span>
			</h2>
		</div>
		<div class="login-widget animation-delay1">	
			<div class="panel panel-default">
				<div class="panel-heading clearfix">
					<div class="pull-left"> 登录 </div>
					<div class="pull-right">
						<span style="font-size:11px;">还没有账号?</span>
						<a class="btn btn-default btn-xs login-link" href="/user/toSignin" style="margin-top:-2px;">注册</a>
					</div>
				</div>
				<div class="panel-body">
					<form class="form-login" id="loginForm">
						<div class="form-group">
							<label>姓名:</label>
							<input type="text" placeholder="请输入姓名" name= "userName" class="form-control input-sm bounceIn animation-delay2" >
						</div>
						<div class="form-group">
							<label>密码:</label>
							<input type="password" placeholder="请输入密码" name="password" class="form-control input-sm bounceIn animation-delay4">
						</div>
						<div class="seperator"></div>

						<hr/>
						<div class="form-group">
							<a href="/user/toSignin">忘记密码?</a>
							<a class="btn btn-success btn-sm bounceIn animation-delay5 login-link pull-right" href="#" id="submitButton">登录</a>
						</div>	
					</form>
				</div>
			</div>
		</div>
	</div>
	<script language="javascript">

	$("#submitButton").click(function(){
		if($('#loginForm').parsley().validate()){
			$.ajax({
			cache: true,
			type: "POST",
			url:"/user/loginIn",
			data:$('#loginForm').serialize(),
			async: false,
			error: function(request) {
				alertify.alert("错误：服务器异常！");
			},
			success: function(data) {
				if(data.success){
						location.href="/train/list";
				}
				else{
					alertify.alert("错误:" + data.message);
				}
			}
		});
		}
	});
	</script>
  </body>

</html>